<template>
  <page-meta :page-style="$theme.pageStyle">
    <!-- #ifndef H5 -->
    <navigation-bar
        :front-color="$theme.navColor"
        :background-color="$theme.navBgColor"
    />
    <!-- #endif -->
  </page-meta>
  <view class="index" :style="{backgroundImage: `url(${$domain}/static/icons/matchmaker/posterBg.png)`}">

    <!--顶部-->
    <u-navbar
        :safeAreaInsetTop="false"
        :placeholder="false"
        :is-back="true"
        :is-fixed="true"
        :backIconColor="titleColor"
        :title="'实名奖励'"
        :border-bottom="false"
        :title-bold="true"
        :title-color="titleColor"
        :background="{ background : navBg }"
    >
    </u-navbar>


    <view class="page-data">
      <view class="data-item">
        <view class="item-number">
          {{ disInfo.xia_user_dshrs }}
        </view>
        <view class="item-text">
          待审核人数
        </view>
      </view>
      <view class="data-item">
        <view class="item-number">
          {{ disInfo.xia_user_tgrs }}
        </view>
        <view class="item-text">
          通过人数
        </view>
      </view>
      <view class="data-item">
        <view class="item-number">
          {{ disInfo.xia_user_wtgrs }}
        </view>
        <view class="item-text">
          未通过人数
        </view>
      </view>
    </view>

    <view class="page-reward">
      <view class="reward-top">
        <image class="top-icon" mode="aspectFit" :src="`${$domain}/static/icons/matchmaker/idea_fff.svg`"></image>
        <view class="tip-text">
          资料审核通过后才获得奖励哦~
        </view>
      </view>
      <view class="page-box reward-box">
        <view class="box-top">
          <view class="top-name">
            奖励标准
          </view>
        </view>
        <view class="box-list">
          <view class="list-child">
            <image class="child-pic" :src="`${$domain}/static/icons/matchmaker/nan.svg`" mode="aspectFit"></image>
            <view class="child-text">
              <view class="w-full flex-shrink">
                男会员
              </view>
              <view class="child-money flex-shrink">
                {{ disInfo.reward_man }}
              </view>
              <view>
                元/人
              </view>
            </view>
          </view>
          <view class="list-child">
            <image class="child-pic" :src="`${$domain}/static/icons/matchmaker/nv.svg`" mode="aspectFit"></image>
            <view class="child-text">
              <view class="w-full flex-shrink">
                女会员
              </view>
              <view class="child-money flex-shrink">
                {{ disInfo.reward_girl }}
              </view>
              <view>
                元/人
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>

    <view class="page-reward">
      <view class="page-box reward-box">
        <view class="box-top">
          <view class="top-name">
            人员列表
          </view>
          <view class="top-list">
            <view class="list-btn" @click="navChange(index)" :class="{active : navCurrent === index}" v-for="(item,index) in navList" :key="index">
              {{item.name}}
            </view>
          </view>
        </view>
        <view class="box-search">
          <input v-model="searchName" type="text" class="search-input" placeholder="输入会员昵称/编号">
          <u-icon @click="searchBtn" class="search-icon" name="search" size="30rpx" :color="$theme.primaryColor"></u-icon>
        </view>
        <view class="page-item" v-for="(item,index) in MyCollectBranch.lists" :key="index">
          <image class="item-pic" :src="item.avatar"
                 mode="aspectFill"></image>
          <view class="item-data">
            <view class="data-top">
              <view class="top-name">
                {{ item.nickname }}
              </view>
              <view class="top-sex" v-if="item.sex == '男'">
                <u-icon class="sex-icon" size="22rpx" color="#fff" name="man"></u-icon>
              </view>
              <view class="top-sex top-sexNv" v-if="item.sex == '女'">
                <u-icon class="sex-icon" size="22rpx" color="#fff" name="woman"></u-icon>
              </view>
              <view class="top-label" v-if="item.is_vip == 1">
                <image :src="`${$domain}/static/icons/matchmaker/vip_ying.svg`" class="label-icon" mode="aspectFill"></image>
                <view>{{ item.vip_title }}</view>
              </view>
            </view>
            <view class="data-id">
              ID: {{ item.sn }}
            </view>
          </view>
          <view class="item-type" v-if="item.is_vip == 1">
            已开通{{ item.vip_title }}会员
          </view>
        </view>
<!--        <view class="page-item">-->
<!--          <image class="item-pic" src="https://q4.itc.cn/q_70/images03/20240601/5e733030064642a98aaf7b6650ea4c68.png"-->
<!--                 mode="aspectFill"></image>-->
<!--          <view class="item-data">-->
<!--            <view class="data-top">-->
<!--              <view class="top-name">-->
<!--                小萌新-->
<!--              </view>-->
<!--              <view class="top-sex">-->
<!--                <u-icon class="sex-icon" size="22rpx" color="#fff" name="woman"></u-icon>-->
<!--              </view>-->
<!--              <view class="top-label">-->
<!--                <image :src="`${$domain}/static/icons/matchmaker/vip_ying.svg`" class="label-icon" mode="aspectFill"></image>-->
<!--                <view>银卡</view>-->
<!--              </view>-->
<!--            </view>-->
<!--            <view class="data-id">-->
<!--              ID: 56375678-->
<!--            </view>-->
<!--          </view>-->
<!--          <view class="item-type">-->
<!--            已开通银卡会员-->
<!--          </view>-->
<!--        </view>-->
      </view>
    </view>

  </view>
</template>

<script setup lang="ts">
import {computed, reactive, ref} from 'vue'
import {onLoad, onPageScroll, onReachBottom, onShow} from "@dcloudio/uni-app";
import {getDisInfoApi, getUserInfoApi, getMyCollectBranchListApi, getInviteUserListApi} from "@/api/new";


const titleColor = ref<string>('#fff')
const navBg = ref<string>('rgba(255,255,255,0)')

onPageScroll((event: any) => {
  navBg.value = event.scrollTop > 10 ? '#fff' : 'rgba(255,255,255,0)'
  titleColor.value = event.scrollTop > 10 ? '#111' : '#fff'
})

const getPercent = (num:any, total:any) => {
  /// <summary>
  /// 求百分比
  /// </summary>
  /// <param name="num">当前数</param>
  /// <param name="total">总数</param>
  num = parseFloat(num);
  total = parseFloat(total);
  if (isNaN(num) || isNaN(total)) {
    return "-";
  }
  return total <= 0 ? "0" : (Math.round(num / total * 10000) / 100.00);
}


let searchName = ref()

const searchBtn = () => {
  formData.value.nickname = searchName.value
  getMyCollectBranchList()
}

const navChange = (item: any) => {
  navCurrent.value = item
  MyCollectBranch.value.lists = []
  formData.value = {
    page_no: 1,
    page_size: 20,
    nickname: '',
    class: navList.value[navCurrent.value].id
  }
  getMyCollectBranchList()
}

const navCurrent = ref(0)
const navList = ref([
  {
    name: '全部',
    id: 0,
  },
  {
    name: '男',
    id: 1,
  },
  {
    name: '女',
    id: 1,
  }
])

const navTo = (url: any) => {
  uni.navigateTo({url})
}


const disInfo = ref()


let theUserInfo = ref()
const isShowMain = ref(false)
const getTheUserInfo = async () => {
  theUserInfo.value = await getUserInfoApi({})
  if (theUserInfo.value.is_dis == 0) {
    uni.redirectTo({
      url: '/packagesA/pages/matchmakerAdd/matchmakerAdd'
    })
  } else {
    getDisInfo()
  }
}

const getDisInfo = async () => {
  disInfo.value = await getDisInfoApi({})
  getMyCollectBranchList()
}


onLoad(() => {
  getTheUserInfo()
})


let formData = ref({
  page_no: 1,
  page_size: 10,
  class: navList.value[navCurrent.value].id
}) as any

let MyCollectBranch = ref({
  lists: []
})

const getMyCollectBranchList = async () => {
  const data: any = await getInviteUserListApi(formData.value)
  MyCollectBranch.value.lists.push(...data.lists)
  isShowMain.value = true
}

onReachBottom(() => {
  if (MyCollectBranch.value.lists.length < MyCollectBranch.value.count) {
    formData.value.page_no++
    getMyCollectBranchList()
  }
})
</script>

<style lang="scss" scoped>
.index {
  padding-bottom: 60rpx;
  position: relative;
  background-repeat: no-repeat;
  background-size: cover;
  overflow: hidden;
  width: 100%;
  transition: all 1s;
  min-height: calc(100vh - env(safe-area-inset-bottom));
}

.page-data {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20rpx;
  padding: 30rpx;

  .data-item {
    text-align: center;
    font-size: 28rpx;
    color: #ffffff;

    .item-number {
      font-size: 34rpx;
      font-weight: bold;
      color: #ffffff;
    }
  }
}

.page-reward {
  width: calc(100% - 60rpx);
  margin: 0 auto;

  .reward-top {
    padding: 20rpx 20rpx 50rpx 20rpx;
    color: #ffffff;
    font-size: 24rpx;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 30rpx 30rpx 0 0;
    margin-bottom: -30rpx;

    .top-icon {
      width: 28rpx;
      height: 28rpx;
      margin-right: 10rpx;
    }
  }

  .reward-box {
    margin-top: 0;
    .box-top {
      .top-list {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        .list-btn {
          padding: 6rpx 20rpx;
          background: #F1F8FF;
          color: var(--color-primary);
          font-size: 28rpx;
          border-radius: 40rpx;
          margin-left: 20rpx;
        }
        .active {
          color: #ffffff;
          background: linear-gradient(to right, var(--color-primary), var(--color-minor));
        }
      }
    }
    .box-search {
      border: 1rpx solid #5BA3F5;
      width: 100%;
      padding: 15rpx 30rpx;
      border-radius: 40rpx;
      background-color: #ffffff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .search-input {
        width: 100%;
      }
      .search-icon {
        flex-shrink: 0;
      }
    }
    .box-list {
      margin-top: 30rpx;
      display: grid;
      grid-template-columns: repeat(2,1fr);
      gap: 20rpx;
      .list-child {
        padding: 20rpx;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        font-size: 24rpx;
        color: #111111;
        background-color: #F3F8FE;
        border-radius: 30rpx;
        font-weight: bold;
        .child-pic {
          width: 70rpx;
          height: 70rpx;
          border-radius: 50%;
          margin-right: 20rpx;
          flex-shrink: 0;
        }
        .child-text {
          display: flex;
          align-items: center;
          flex-wrap: wrap;
        }
      }
      .child-money {
        color: var(--color-primary);
      }
    }
  }
}

$color-primary: var(--color-primary);  //var(--color-primary) 主色
$color-minor: var(--color-minor);  //var(--color-minor) 副色


.page-item {
  margin: 20rpx auto;
  padding: 30rpx 20rpx;
  border-radius: 20rpx;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: linear-gradient(105deg, #F0F7FF 0%, #FAFCFF 56%);
  position: relative;

  .item-pic {
    width: 110rpx;
    height: 110rpx;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .item-data {
    width: 100%;
    margin-left: 20rpx;

    .data-top {
      display: flex;
      align-items: center;

      .top-name {
        font-size: 36rpx;
        color: #111111;
        font-weight: bold;
      }

      .top-sex {
        background-color: #669cff;
        width: 30rpx;
        height: 30rpx;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        text-align: center;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
        &Nv {
          background-color: #FF668A;
        }

        .sex-icon {
          display: inline-block;
          margin-left: 2rpx;
        }
      }

      .top-label {
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2rpx solid #CCBBFF;
        padding: 4rpx 20rpx;
        border-radius: 40rpx;
        line-height: normal;
        font-size: 30rpx;
        transform: scale(0.8);

        .label-icon {
          width: 30rpx;
          height: 30rpx;
          margin-right: 10rpx;
        }
      }

    }

    .data-line {
      overflow: hidden;
      margin-top: 10rpx;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      border-radius: 40rpx;
      font-size: 24rpx;
      color: #ffffff;
      position: relative;
      &:before {
        content: '';
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
        background-color: var(--color-primary);
        opacity: 0.1;
      }

      .line-left {
        flex-shrink: 0;
        border-radius: 40rpx 10rpx 70rpx 40rpx;
        padding: 4rpx 24rpx 4rpx 20rpx;
        background-image: linear-gradient(to right, $color-primary, $color-minor);
        margin-right: 20rpx;
        position: relative;
      }

      .line-right {
        color: $color-primary;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        max-width: 30%;
      }
    }

    .data-bottom {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 20rpx;
      .bottom-user {
        display: flex;
        align-items: center;
        font-size: 24rpx;
        color: #999;
        .user-img {
          display: flex;
          align-items: center;
          flex-shrink: 0;
          margin-left: 15rpx;
          margin-right: 10rpx;

          .img-one {
            flex-shrink: 0;
            width: 50rpx;
            height: 50rpx;
            margin-left: -25rpx;
            border-radius: 50%;
            border: 2rpx solid #fff;
            box-shadow: 0 0 20rpx -10rpx rgba(0, 0, 0, 0.5);
          }
        }
      }
      .bottom-btn {
        padding: 10rpx 30rpx;
        background-image: linear-gradient(to right, $color-primary,$color-minor);
        position: relative;
        overflow: hidden;
        font-size: 28rpx;
        color: #ffffff;
        font-weight: bold;
        border-radius: 80rpx;
        .btn-pic {
          width: 100rpx;
          height: 100rpx;
          position: absolute;
          left: 0;
          top: 0;
          transform: translateX(-20%);
        }
      }
    }

    .data-id {
      color: #999999;
      font-size: 24rpx;
    }
  }
  .item-type {
    padding: 10rpx 30rpx;
    background-color: rgba(0,0,0,0.03);
    border-radius: 20rpx 0 20rpx 0;
    font-size: 24rpx;
    color: var(--color-primary);
    position: absolute;
    bottom: 0;
    right: 0;
  }
}
</style>
